package com.boot.web;

import com.boot.task.MyAsyncTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Chunsheng.Zhang
 * @date 2021/1/7 11:38
 * @description : TODO
 */
@Controller
public class TaskController {

    @Autowired
    private MyAsyncTask asyncTask;


    @GetMapping("/test")
    @ResponseBody
    public String test() throws InterruptedException {
        long start = System.currentTimeMillis();
        asyncTask.task1();//3s

        asyncTask.task2();//2s

        asyncTask.task3();//3s;
        long end = System.currentTimeMillis();
        return ("任务全部完成，总耗时："+(end-start)+"毫秒");
    }




}
